<template>
  <view class="axios-demo">
    <view class="title-h1">Axios Page</view>
    <view>{{ '未发起请求' }}</view>
    <view>{{ '未发起请求' }}</view>
    <view>{{ '加载中' }}</view>
    <button @click="getPosts">获取获取公共数据</button>
    <button>测试useRequest</button>
    <button>上传文件</button>
  </view>
</template>
<script lang="ts" setup>
import { getPosts } from '@/apis/demo/demo'
// onMounted(() => {
//   getPosts()
// })

// import { useRequest } from 'vue-request'
// import { ref, computed } from 'vue'
// import { getCommonData, uploadFile } from '@/api/sys/common'

// const { run, data, loading } = useRequest(getCommonData, {
//   manual: true
// })

// const common = ref<any>(null)
// const fetchPost = async () => {
//   const result = await getCommonData()
//   common.value = result.data
// }

// const phoneData = computed(() => data.value?.data)

// const testVueRequest = () => {
//   run()
// }

// const upload = () => {
//   uni.chooseImage({
//     success: async (chooseImageRes) => {
//       const { tempFilePaths } = chooseImageRes
//       const result = await uploadFile({ filePath: tempFilePaths[0] })
//       console.log(result.data.fileInfo.preview_url)
//     }
//   })
// }
</script>

<style lang="less" scoped>
.axios-demo {
  text-align: center;
}

.title-h1 {
  font-size: 50rpx;
}
</style>
